//
// Created by yunnan xu on 2020/12/7.
//

#ifndef ANDROIDGRAPHICSDEMOS_MeshModel_H
#define ANDROIDGRAPHICSDEMOS_MeshModel_H

#include "Model.h"
#include "EngineCore.h"
#include "VertexAttrib.h"
#include <unordered_set>
#include <assimp/mesh.h>
#include "assimp/Importer.hpp"
#include <vector>

class MeshModel : public Model
{
public:
    MeshModel(const char * model_path, std::unordered_set<VertexAttribType> _attrib_list);

    virtual ~MeshModel();
    virtual int GetVertexNumber() const;
    virtual int GetFaceNumber() const;
    virtual const void * GetVertexData(VertexAttribType attrib_type) const;
    virtual size_t GetVertexDataLength(VertexAttribType attrib_type) const;
    virtual const void * GetIndexData() const;
    virtual size_t GetIndexDataLength() const;
    virtual GLenum GetIndexType() const;

    void InitVertexAttrib(VertexAttribType va_type);

protected:

    Assimp::Importer importer;
    void * modelFileContent;
    int vertexNumber;
    int faceNumber;
    int meshNumber;

    const aiScene * ai_scene;
    aiMesh ** meshes;

    std::unordered_map<VertexAttribType, uint8_t*> vertex_data;
    std::vector<uint32_t> index_data;
    std::unordered_set<VertexAttribType> attrib_list;
};


#endif //ANDROIDGRAPHICSDEMOS_MeshModel_H
